<%@ include file="/head.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html:html locale="true">
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<title>left</title>
</head>
<script src="js/tree.js"></script>
<script type="text/javascript" src="js/p.js"></script>
<script type="text/javascript" src="js/s.js"></script>
<script type="text/javascript" src="js/m.js"></script>

<link type="text/css" rel="stylesheet" href="tree.css">
<body>
<div style="position: absolute; width: 200px; top: 10px; left: 0px; height: 100%; padding: 5px; overflow: auto;">
<script type="text/javascript">

var ie55 = /MSIE ((5\.[56789])|([6789]))/.test( navigator.userAgent ) &&
			navigator.platform == "Win32";

if ( !ie55 ) {
	window.onerror = function () {
		return true;
	};
}

function writeNotSupported() {
	//if ( !ie55 ) {
	//	document.write( "<p class=\"warning\">" +
	//		"This script only works in Internet Explorer 5.5" +
	//		" or greater for Windows</p>" );
	//}
}

</script>

<script type="text/javascript">
//<![CDATA[


// set css file to use for menus
Menu.prototype.cssFile = 'css/winxp.css';

var tmp;

// Build context menu
var cMenu = new Menu();

var openItem, openNewWinItem;

cMenu.add( openItem = new MenuItem( "Open" ) );
openItem.mnemonic = "o";
cMenu.add( openNewWinItem = new MenuItem( "Open in New Window" ) );
openNewWinItem.mnemonic = "n";
openNewWinItem.target = "_blank";	// open in new window

var backItem, forwardItem, refreshItem;

cMenu.add( backItem = new MenuItem( "Back", function () { window.history.go(-1); }, "images/back.png" ) );
backItem.mnemonic = "b";
cMenu.add( forwardItem = new MenuItem( "Forward", function () { window.history.go(1); }, "images/forward.png" ) );
forwardItem.mnemonic = "o";
cMenu.add( refreshItem = new MenuItem( "Refresh", function () { document.location.reload(); }, "images/refresh.png" ) );
refreshItem.mnemonic = "r";

cMenu.add( new MenuSeparator() );

cMenu.add( tmp = new MenuItem( '<bean:message key="menu.newEngine"/>', "engine.do?act=new", "images/engine.jpg" ) );
tmp.target="mainFrame";
cMenu.add( tmp = new MenuItem( '<bean:message key="menu.newTaskManager"/>', "task.do?act=new", "images/task.jpg" ) );
tmp.target="mainFrame";
cMenu.add( tmp = new MenuItem( '<bean:message key="menu.newOrgManager"/>', "org.do?act=new", "images/grouptype.jpg" ) );
tmp.target="mainFrame";
cMenu.add( tmp = new MenuItem( '<bean:message key="menu.newDataConnection"/>', "database.do?act=new", "images/database.jpg" ) );
tmp.target="mainFrame";

var oldOpenState = null;	// used to only change when needed
var lastKeyCode = 0;

function rememberKeyCode() {
	lastKeyCode = window.event.keyCode;
}

function showContextMenu() {

	var el = window.event.srcElement;

	while ( el != null && el.tagName != "A" )
		el = el.parentNode;

	var showOpenItems = el != null && el.tagName == "A";

	if ( showOpenItems != oldOpenState ) {
		openItem.visible		= showOpenItems;
		openNewWinItem.visible	= showOpenItems;
		backItem.visible		= !showOpenItems;
		forwardItem.visible		= !showOpenItems;
		refreshItem.visible		= !showOpenItems;
		oldOpenState = showOpenItems;
	}

	if ( showOpenItems ) {
		openItem.action = openNewWinItem.action = el.href;
	}

	// find left and top
	var left, top;

 if ( !showOpenItems )
		el = document.documentElement;

	if ( lastKeyCode == 93 ) {	// context menu key
		left = posLib.getScreenLeft( el );
		top = posLib.getScreenTop( el );
	}
	else {
		left = window.event.screenX;
		top = window.event.screenY;
	}

		cMenu.invalidate();
		cMenu.show( left, top );
	
	event.returnValue = false;
	lastKeyCode = 0
};

document.attachEvent( "oncontextmenu", showContextMenu );
document.attachEvent( "onkeyup", rememberKeyCode );

//]]>
</script>

<script type="text/javascript">
writeNotSupported();
</script>
<script>
if (document.getElementById) {
	var tree = new Tree('<bean:message key="menu.engines"/>');
	tree.setBehavior('classic');
//	tree.icon = 'images/engine_folder.jpg';
//	tree.openIcon = 'images/engine_folder.jpg';

 var domainname;
 var domain;
 var process ;
 var thecase;
 var theChiled123;
 var role;
	<logic:notEmpty name="domainlist">
<logic:iterate id="domain" name="domainlist">
	domainname = '<bean:write name="domain" property="id" filter="true"/>';
	domain = new TreeItem(domainname);
	tree.add(domain);
	domain.action = 'engine.do?act=home&domain='+domainname;
	domain.target = 'mainFrame';
	domain.icon = 'images/engine.jpg';
	domain.openIcon = 'images/engine.jpg';
	
	process = new TreeItem('<bean:message key="menu.processDefinitions"/>');
	process.action = 'type.do?act=typeHome&typeType=processType&domain='+domainname;
	process.target = 'mainFrame';
	process.icon = 'images/process.jpg';
	process.openIcon = 'images/process.jpg';
	domain.add(process);
	{
	<bean:write name="domain" property="tree" filter="false"/>
	}
	thecase = new TreeItem('<bean:message key="menu.processes"/>');
	thecase.icon = 'images/case.jpg';
	thecase.openIcon = 'images/case.jpg';
	domain.add(thecase);
	
	theCaseInRun = new TreeItem('<bean:message key="menu.processesRunning"/>');
	theCaseInRun.action = 'case.do?act=listCaseRunning&domain='+domainname;
	theCaseInRun.target = 'mainFrame';
	thecase.add(theCaseInRun);
	
	theChiled123 = new TreeItem('<bean:message key="menu.processesFinished"/>');
	theChiled123.action = 'case.do?act=listCaseHistory&domain='+domainname;
	theChiled123.target = 'mainFrame';
	thecase.add(theChiled123);
	
	role = new TreeItem('<bean:message key="menu.roles"/>');
	role.action = 'role.do?act=roleHome&roleType=process&domain='+domainname;
	role.target = 'mainFrame';
	role.icon = 'images/role.jpg';
	role.openIcon = 'images/role.jpg';
	domain.add(role);
</logic:iterate>
</logic:notEmpty>
	document.write(tree);
	
	tree = new Tree('<bean:message key="menu.taskManagers"/>');
	//tree.icon = 'images\engine.jpg';
	tree.setBehavior('classic');
	<logic:notEmpty name="tasklist">
	<logic:iterate id="task" name="tasklist">
	buildTask(tree,'<bean:write name="task" property="id" filter="true"/>');
</logic:iterate>
</logic:notEmpty>
	document.write(tree);
	
	tree = new Tree('<bean:message key="menu.orgManager"/>');
	tree.setBehavior('classic');

	buildOrg(tree);

	document.write(tree);
	//
	var theTimer = new Tree('<bean:message key="menu.timers"/>');
	//theTimer.icon = 'images/timer.jpg';
	//theTimer.openIcon = 'images/timer.jpg';
	theTimer.action = 'timer.do?act=home';
	theTimer.target = 'mainFrame';
	
	theCaseInRun = new TreeItem('<bean:message key="menu.timeActivities"/>');
	theCaseInRun.action = 'timer.do?act=listActivity';
	theCaseInRun.target = 'mainFrame';
	theTimer.add(theCaseInRun);
	
	theChiled123 = new TreeItem('<bean:message key="menu.timeProcesses"/>');
	theChiled123.action = 'timer.do?act=listProcess';
	theChiled123.target = 'mainFrame';
	theTimer.add(theChiled123);
	
	theChiled123 = new TreeItem('<bean:message key="menu.taskTimeoutEvents"/>');
	theChiled123.action = 'timer.do?act=listDeadline';
	theChiled123.target = 'mainFrame';
	theTimer.add(theChiled123);
	document.write(theTimer);
	//
	tree = new Tree('<bean:message key="menu.messages"/>');
	//tree.icon = 'images/timer.jpg';
	//tree.openIcon = 'images/timer.jpg';
	tree.action = 'message.do?act=home';
	tree.target = 'mainFrame';
	
	var msgDef= new TreeItem('<bean:message key="menu.messageDefinitions"/>');
	msgDef.action = 'message.do?act=listMessage';
	msgDef.target = 'mainFrame';
	tree.add(msgDef);
	
	msgDef = new TreeItem('<bean:message key="menu.messageQueue"/>');
	msgDef.action = 'message.do?act=listMessageQueue';
	msgDef.target = 'mainFrame';
	tree.add(msgDef);
	
	msgDef = new TreeItem('<bean:message key="menu.messageConsumers"/>');
	msgDef.action = 'message.do?act=listMessageConsumer';
	msgDef.target = 'mainFrame';
	tree.add(msgDef);
	document.write(tree);
	//
	tree = new Tree('<bean:message key="menu.componentLibrary"/>');
	tree.setBehavior('classic');

	buildComponent(tree);

	document.write(tree);
	
	tree = new Tree('<bean:message key="menu.dataConnections"/>');
	
	tree.setBehavior('classic');
	<logic:notEmpty name="databaselist">
	<logic:iterate id="database" name="databaselist">
	buildDatabase(tree,'<bean:write name="database" property="id" filter="true"/>');
	</logic:iterate>
	</logic:notEmpty>
	document.write(tree);
	
	tree = new Tree('<bean:message key="menu.subscription"/>');
	tree.setBehavior('classic');
	tree.action = 'logon.do?act=LicenseInfo';
	tree.target = 'mainFrame';
	tree.icon = 'images/license.gif';
	tree.openIcon = 'images/license.gif';
	document.write(tree);
}

function buildDomain(tree,domainname){
	var domain = new TreeItem(domainname);
	tree.add(domain);
	domain.action = 'engine.do?act=home&domain='+domainname;
	domain.target = 'mainFrame';
	domain.icon = 'images/engine.jpg';
	domain.openIcon = 'images/engine.jpg';
	
	var process = new TreeItem('<bean:message key="menu.processDefinitions"/>');
	process.action = 'type.do?act=typeHome&typeType=processType&domain='+domainname+'&title='+domainname+'&gt;<bean:message key="menu.processDefinitions"/>';
	process.target = 'mainFrame';
	process.icon = 'images/process.jpg';
	process.openIcon = 'images/process.jpg';
	domain.add(process);
	
	var bb = new TreeItem('<bean:message key="menu.processDefinitionsBuilding"/>');
	bb.action = 'processManagement.do?act=listProcessInDev&domain='+domainname;
	bb.target = 'mainFrame';
	process.add(bb);
	
	bb = new TreeItem('<bean:message key="menu.processDefinitionsReady"/>');
	process.add(bb);
	
	bb = new TreeItem('<bean:message key="menu.processDefinitionsUsed"/>');
	process.add(bb);
	
	
}

function buildTask(tree,taskname){
	var task = new TreeItem(taskname);
	tree.add(task);
	task.action = 'task.do?act=home&domain='+taskname;
	task.target = 'mainFrame';
	task.icon = 'images/task.jpg';
	task.openIcon = 'images/task.jpg'; 
	var workitem = new TreeItem('<bean:message key="menu.taskes"/>');
	task.add(workitem);
	
	
	bb = new TreeItem('<bean:message key="menu.taskesTodo"/>');
	bb.action = 'task.do?act=listPersonItem&domain='+taskname;
	bb.target = 'mainFrame';
	workitem.add(bb);
	
	bb = new TreeItem('<bean:message key="menu.taskesFinished"/>');
	bb.action = 'task.do?act=listHistoryItem&domain='+taskname;
	bb.target = 'mainFrame';
	workitem.add(bb);
	
	var role = new TreeItem('<bean:message key="menu.roles"/>');
	role.action = 'role.do?act=roleHome&roleType=workitem&domain='+taskname;
	role.target = 'mainFrame';
	role.icon = 'images/role.jpg';
	role.openIcon = 'images/role.jpg';
	task.add(role);
}

function buildDatabase(tree,databasename){
	var database = new TreeItem(databasename);
	tree.add(database);
	database.action = 'database.do?act=home&domain='+databasename;
	database.target = 'mainFrame';
	database.icon = 'images/database.jpg';
	database.openIcon = 'images/database.jpg'; 
}

function buildOrg(root){
var tree;
var alluser;
var orgname;
<logic:notEmpty name="orglist">
<logic:iterate id="org" name="orglist">
	orgname='<bean:write name="org" property="id" filter="true"/>'
	tree = new TreeItem(orgname);
	root.add(tree);
	tree.action = 'org.do?act=home&domain='+orgname;
	tree.target = 'mainFrame';
	tree.icon = 'images/grouptype.jpg';
	tree.openIcon = 'images/grouptype.jpg'; 
	alluser = new TreeItem('<bean:message key="menu.allUsers"/>');
	tree.add(alluser);
	alluser.action = 'org.do?act=userlist&domain='+orgname;
	alluser.target = 'mainFrame';
<logic:notEmpty name="org" property="orgTree">
	<bean:write name="org" property="orgTree"  filter="false"/>
	</logic:notEmpty>
	</logic:iterate>
</logic:notEmpty>
}
function buildComponent(tree){
	var dataCom = new TreeItem('<bean:message key="menu.dataComponents"/>');
	dataCom.icon = 'images/datacom.jpg';
	dataCom.openIcon = 'images/datacom.jpg'; 
	dataCom.target = 'mainFrame';
	dataCom.action = 'type.do?act=typeHome&typeType=dataType&domain=domain';
	tree.add(dataCom);

	{
	<bean:write name="datatypelist"  filter="false"/>
	}
	
	var actionCom = new TreeItem('<bean:message key="menu.actionComponents"/>');
	actionCom.icon = 'images/actioncom.jpg';
	actionCom.openIcon = 'images/actioncom.jpg';
	actionCom.target = 'mainFrame';
	actionCom.action = 'type.do?act=typeHome&typeType=actionType&domain=domain';
	tree.add(actionCom);
	{
	<bean:write name="actionlist"  filter="false"/>
	}
	
}

</script>

</div>
<bean:write name="engineInfo" filter="false" />
</body>
</html:html>
